import 'package:flutter/material.dart';

class TextDemo extends StatelessWidget {


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(

      appBar: AppBar(title: Text('TextDemo'),),

      //在父级指定默认样式，子组件没有显示的指定属性就会继承父级样式
      body: DefaultTextStyle(

          style: TextStyle(color: Colors.red),

          child: SizedBox(

            width: double.infinity,

            child: Flex(

              direction: Axis.vertical,

              children: <Widget>[

                //调整内部位置
                SizedBox(

                  width: double.infinity,
                  child: Text('Hello Word', textAlign: TextAlign.end,),

                ),

                //省略未显示内容为 ...
                Text("Hello world! I'm Jack. " * 8, maxLines: 1,
                  overflow: TextOverflow.ellipsis,),

                //缩放比例
                Text('Hello world', textScaleFactor: 1.5,),


                //TextStyle
                Text('Hello world',

                  style: TextStyle(

                      color: Colors.blue,
                      fontSize: 15.0,
                      height: 4.2,
                      //行高，非固定值，等于 fontSize * height,但是不影响背景颜色的范围
//                background: Paint()..color = Colors.blueGrey,
                      backgroundColor: Colors.greenAccent,
                      decoration: TextDecoration.underline,
                      //各种线
                      decorationStyle: TextDecorationStyle.dashed //线的样式

                  ),
                ),

                //TextSpan
                Text.rich(TextSpan(

                    children: [

                      TextSpan(

                          text: '万恶之源'
                      ),

                      TextSpan(

                        text: 'http://www.baidu.com',

                        style: TextStyle(color: Colors.blue),

                      )
                    ]

                ))
              ],

            ),
          )),
    );
  }
}